﻿namespace hr_1.Model
{
    public class Person
    {
        HRDataContext hrData = new HRDataContext();
        public int PersonId { get; set; }
        public string Firstname { get; set; }
        public string Middlename { get; set; }
        public string Lastname { get; set; }
        public string Sex { get; set; }
        public string Birthday { get; set; }
        public string Date_begin_work { get; set; }
        public int PersonalDocId { get; set; }
        public int PersonalInfoId { get; set; }
        public int WorkActivityId { get; set; }

        public Person() { }

        public void Save()
        {
            person NewPerson = new person
                {
                    firstname = Firstname,
                    middlename = Middlename,
                    lastname = Lastname,
                    birthday = Birthday,
                    sex = Sex,
                    date_begin_work = Date_begin_work,
                    personal_docId = PersonalDocId,
                    personal_infoId = PersonalInfoId,
                    work_activityId = WorkActivityId
                };
            hrData.persons.InsertOnSubmit(NewPerson);
            hrData.SubmitChanges();
            PersonId = NewPerson.personId;
        }
    }
       
}
